﻿package bits;

/**
 * 交换两个变量
 * 
 * @author Administrator
 *
 */
public class SwapTwoNums {
	private int a;
	private int b;

	public void swap() {
		a = a ^ b;
		b = a ^ b;
		a = a ^ b;
	}

	public SwapTwoNums(int a, int b) {
		this.a = a;
		this.b = b;
	}

	public void print() {
		System.out.println("a=" + a);
		System.out.println("b=" + b);
	}

	public static void main(String[] args) {
		SwapTwoNums test = new SwapTwoNums(32, 12);
		test.swap();
		test.print();
	}
}
